{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "555f40ec-8267-405e-865d-656570f0f83a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "13d8570aaee242fea96571c2acde4fc6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "IntSlider(value=0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import ipywidgets as widgets\n",
    "from IPython.display import display\n",
    "\n",
    "w = widgets.IntSlider()\n",
    "display(w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "50933999-849b-43d2-ba52-262b5dd0ca11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9c8d0a877e7540509429ea08310619e5",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Text(value='Hello World!')"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Text 文本输入\n",
    "text = widgets.Text(value=\"Hello World!\", disable=True)\n",
    "display(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a80c76d7-9871-4446-831c-38292952f6d2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "9a2cb910276f4e9c869277809a0ceaf0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FloatText(value=0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4cbb6b87426b4145b62b5d938ea1665b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FloatSlider(value=0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 显示多个\n",
    "a = widgets.FloatText()\n",
    "b = widgets.FloatSlider()\n",
    "display(a,b)\n",
    "# 关联变量控件值, a的值改变，b的值也会改变\n",
    "mylink = widgets.jslink((a,\"value\"), (b,\"value\"))\n",
    "# mylink.unlink() # 取消关联"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
